<?php
/**
 * Created by PhpStorm.
 * User: jwb
 * Date: 2021/4/29
 * Time: 16:28
 */

namespace App\Extensions\Tools;


use Illuminate\Database\Eloquent\Collection;

class FruitReleaseBatch extends BatchAction
{
    protected $selector = '.goods-release-batch';

    public function handle(Collection $collection)
    {
        foreach ($collection as $model) {
            if ($model->review_status == 1 && !$model->state) {
                $model->state = 1;
                $model->save();
            }
        }
        return $this->response()->swal()->success('操作成功!')->refresh();
    }

    public function dialog()
    {
        $this->confirm('确定发布？');
    }

    public function name()
    {
        return "<a class='goods-release-batch btn btn-sm btn-danger'><i class='fa fa-location-arrow'></i>&nbsp;成果发布</a>";
    }
}